<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      xmlns:th="http://www.thymeleaf.org"
      layout:decorator="backstage/layout">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
    <title>广告管理</title>
</head>
<body>
<div id="content" layout:fragment="content">
<script type="text/javascript">
	  
		
        $("div").delegate(".btn-setting","click",function(){
            $("#addResult").click();
            return true;
        });      
        $(function(){  
             
        	 $('#loseDiv').click(function(e){  	   		 
     	        window.location.href ="/content/contentList.htm";
     	            
     	    });

            $('.date-picker').datepicker().next().on(ace.click_event, function () {
                $(this).prev().focus();
            });
            $('#spinner2').ace_spinner({value: 0, min: 0, max: 1000000000, step: 100, icon_up: 'icon-caret-up', icon_down: 'icon-caret-down'});
            $('#edit-numberUnit').ace_spinner({value: 0, min: 0, max: 1000000000, step: 100, icon_up: 'icon-caret-up', icon_down: 'icon-caret-down'});
                
            var imgUrl=$("#hidden-advertImg").val();
            if(imgUrl==""){
            	imgUrl="没有文件 ...";
            }
            $('#edit-advertImg').ace_file_input({
                no_file: imgUrl,
                btn_choose: 'Choose',
                btn_change: 'Change',
                droppable: false,
                onchange: null,
                thumbnail: false//| true | large
//                whitelist:'xls|xlsx'
               //blacklist:'exe|php'
               //onchange:''
            });
            
            var status=$("#edit-status").val();                
            if(status==1){
            	$("#edit-status1").click();
            }else{
            	$("#edit-status2").click();           	
            }
            
			//提交更新
            $("#editcontent").validate( {
                checkStart : true,
                errorElement: 'span',
                errorClass: 'help-inline',
                focusInvalid: false,
                rules : {
                	/* name:{
                		required: true
                	}, */
                	title : {
                        required: true                       
                    }
                    /* file:{
                    	required:true
                    } */
                },
                messages : {
                	/* name : {
                        required: "请填写广告位名称"
                    }, */
                    title:{
                    	required: "请填写标题"
                    }                                     
                    /* file:{
                    	required: "请填写图片"
                    } */
                },
                submitHandler : function(form) {                  	
                    $("#editcontent").ajaxSubmit(function(date){
                        if(date.suc){
                            alert("操作成功了！");
                            $(".close").click();
                            window.location.href = "/tadvert/list.htm";
                        }else {
        	                alert("保存失败了！" + date.msg);
        	            }
                    });
                }, 
                highlight: function (e) {
                    $(e).closest('.control-group').removeClass('info').addClass('error');
                }
            });
            
        });

        
		
		
    </script> 
<!--  发布广告    -->
	<div class="box-content">
        <div class="row-fluid sortable">
         <div class="box span12" style="height:650px;max-height:650px;">
            <h3 class="row-fluid header smaller lighter blue">
                 <span class="label label-large label-pink arrowed-right" th:text="${tadvert.id==null?'广告添加':'广告编辑'}"></span>
             </h3>
            <form class="form-horizontal" style="margin: 0" action="/tadvert/addOrUpdate.json" method="post" id="editcontent" enctype="multipart/form-data">
                <input id="edit-id" name="id" type="hidden" th:value="${tadvert.id}"/>
                <input id="edit-createTime" name="createTime" type="hidden" th:value="${tadvert.createTime}"/>
                <input id="edit-createUser" name="createUser" type="hidden" th:value="${tadvert.createUser}"/> 
                <input id="edit-status" type="hidden" th:value="${tadvert.status}"/>              
                <fieldset>
                    <div class="modal-body" style="height:550px;max-height:550px;">
                    	<input type="hidden" name="name" id="edit-name" th:value="${tadvert.name}" />
                    	<!-- <div class="control-group">
                            <label class="control-label">广告位名称：</label>

                            <div class="controls">
                                <input type="text" name="name" id="edit-name" th:value="${tadvert.name}" class="input-xlarge"/>
                            </div>
                        </div> -->
                        <div class="control-group">
                            <label class="control-label">标题：</label>

                            <div class="controls">
                                <input type="text" name="title" id="edit-title" th:value="${tadvert.title}" class="input-xxlarge"/>
                            </div>
                        </div>
                        <div class="control-group">
	                        <label class="control-label">图片：</label>
	                        <div class="controls">
	                            <div class="widget-main" style="padding:0px;width:283px;">
		                        	<input type="file" id="edit-advertImg" name="file" />
		                        	<input type="hidden" id="hidden-advertImg" th:value="${tadvert.advertImg}"/>
			                    </div>
	                        </div>
                        </div>
                        
                        <div class="control-group">
                            <label class="control-label">广告指向地址：</label>

                            <div class="controls">
                               <input type="text" name="advertUrl" id="edit-advertUrl" th:value="${tadvert.advertUrl}" class="input-xxlarge"/>
                            </div>
                        </div>
                        
                        <div class="control-group">
                            <label class="control-label">广告内容：</label>

                            <div class="controls">
                                <textarea  id="edit-content" th:text="${tadvert.content}" style="width:48%;height:100px;" name="content"></textarea>                               
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">广告备注：</label>

                            <div class="controls">
                                <textarea  id="edit-memo" th:text="${tadvert.memo}" style="width:48%;height:100px;" name="memo"></textarea>                               
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">广告状态：</label>
                            <div class="controls">
	                           	<input type="radio" value="1" name="status" id="edit-status1"/>开启	
	                           	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	                           	<input type="radio" value="2" name="status" id="edit-status2"/>关闭	
	                           	<input type="hidden" th:value="${tadvert.status}" id="edit-status"/>
                           	</div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <input type="submit" class="btn btn-primary btn-small" value="保存" name="isEmpty"/>
                        <a href="/tadvert/list.htm" class="btn btn-small" data-dismiss="modal">取消</a>
                    </div>
                </fieldset>
            </form>
   		</div>
    </div>
  </div>           
</div>
</body>
</html>